package de.dubiel.plung.client.canvas;

import com.google.gwt.canvas.dom.client.Context2d;

public class Line implements Drawable {
    private int width;
    private String color;
    private Vector start;
    private Vector end;

    public int getWidth() {
        return width;
    }

    public void setWidth(int width) {
        this.width = width;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public Vector getStart() {
        return start;
    }

    public void setStart(Vector start) {
        this.start = start;
    }

    public Vector getEnd() {
        return end;
    }

    public void setEnd(Vector end) {
        this.end = end;
    }

    @Override
    public void draw(Context2d context) {
        context.beginPath();
        context.setStrokeStyle(color);
        context.setLineWidth(width);
        context.moveTo(start.getX(), start.getY());
        context.lineTo(end.getX(), end.getY());
        context.closePath();
        context.stroke();
    }
}
